#include <iostream>
#include <stack>
using namespace std;

int main()
{
    stack<char>num;
    int n,base;
    cin>>n>>base;
    while (n!=0)
    {
        int res=n%base;
        if (res<10)
            num.push(res+'0');
        else
            num.push(res-10+'A');
        n/=base;
    }
    while (!num.empty())
    {
        cout<<num.top();
        num.pop();
    }
}